package migrations

import (
	"gorm.io/gorm"

	"github.com/runningwater/gohub/app/models"
	"github.com/runningwater/gohub/pkg/migrate"
)

func init() {

	type Link struct {
		models.BaseModel

		Name string `gorm:"type:varchar(255);not null"`
		URL  string `gorm:"type:varchar(255);default:null"`

		models.CommonTimestampsField
	}

	up := func(migrator gorm.Migrator, DB *gorm.DB) {
		_ = DB.Set("gorm:table_options", "ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci comment='友情链接'").AutoMigrate(&Link{})
	}

	down := func(migrator gorm.Migrator, DB *gorm.DB) {
		_ = migrator.DropTable(&Link{})
	}

	migrate.Add(up, down, "2025_07_21_091558_add_links_table")
}
